/***************************************************************************
 *   Copyright (C) 2007 by Warren Kenny   				   *
 *   warren.kenny@gmail.com   						   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef GS_LINK_H
#define GS_LINK_H

#include <gsCore/gsCore.h>

template< class T >
class gsLink
{
public:

	///
	/// 	Constructor(s)
	///

	/**
	 *        Default Constructor
	 */
	inline gsLink();
	
	/**
	 *        Constructor, initializes this gsLink with the same data as \a other
	 * @param other The other gsLink
	 */
	inline gsLink( const gsLink& other );
	
	/**
	 *        Constructor, sets the contained object to \a object
	 * @param object The object to be contained
	 */
	inline gsLink( const T& object );
	
	/**
	 * 	Constructor, sets the contained object to \a object and the previous and next links to \a previous
	 *	and \a next respectively
	 * @param object The object to be contained
	 * @param previous Pointer to the previous gsLink
	 * @param next Pointer to the next gsLink
	 */
	inline gsLink( const T& object, gsLink<T>* previous, gsLink<T>* next );
	
	///
	/// 	Native Method(s)
	///
	
	/**
	 *        Sets the contained object to \a object
	 * @param object The object to be contained
	 */
	inline void set( const T& object );
	 
	/**
	 *        Retrieves the contained object from the gsLink
	 * @return A reference to the contained object
	 */
	inline T& get();
	
	/**
	 *        Retrieves a constant reference to the contained object from the gsLink
	 * @return A constant reference to the contained object
	 */
	inline const T& get() const;
	
	/**
	 *        Sets the previous and next gsLink pointers for this object
	 * @param previous Pointer to the previous gsLink
	 * @param next Pointer to the next gsLink
	 */
	inline void setLinks( gsLink<T>* previous, gsLink<T>* next );
	
	/**
	 *        Sets the next gsLink
	 * @param next Pointer to the new next gsLink
	 */
	inline void setNext( gsLink<T>* next );
	
	/**
	 *        Gets the next gsLink pointed to by this gsLink
	 * @return The next gsLink or GS_NULL if no next gsLink has been set
	 */
	inline gsLink<T>* next();
	
	/**
	 *        Sets the previous gsLink
	 * @param previous Pointer to the new previous gsLink
	 */
	inline void setPrevious( gsLink<T>* previous );
	
	/**
	 *        Gets the previous gsLink pointed to by this gsLink
	 * @return The previous gsLink or GS_NULL if no previous gsLink has been set
	 */
	inline gsLink<T>* previous();
	
	///
	/// 	Destructor(s)
	///
	
	/**
	 *        Default destructor
	 */
	inline ~gsLink();
	

private:

	gsLink<T>* m_next;
	
	gsLink<T>* m_previous;
	
	T m_object;

};

#include <gsContainer/gsLink.inl>

#endif /// GS_LINK_H
			 